﻿using Serilog;
using System;
using System.Collections.Generic;
using System.IO;

namespace Common
{
    public class Util
    {
        static Util()
        {
            var log = new LoggerConfiguration()
             //.Enrich.WithProperty("appName", "Task_App")
             .Enrich.WithProcessId()
             .Enrich.WithProcessName()
             .Enrich.WithThreadId()
             .Enrich.WithMachineName()
             .Enrich.WithUserName()
             .Enrich.WithAssemblyName()
             .Enrich.WithAssemblyVersion(true)
             .Enrich.WithMemoryUsage()
             .WriteTo.Console(
                 outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {AssemblyName} {AssemblyVersion} {MemoryUsage} [{Level:u3}] [{ProcessId}] [{ProcessName}] [{ThreadId}] [{MachineName}] [{UserName}] [{Message:lj}]{NewLine}{Exception}{NewLine}------------------------------------------------------------------------{NewLine}"
              )
             //.WriteTo.File("logs\\myapp.txt", rollingInterval: RollingInterval.Day)
             .WriteTo.Debug()
             .CreateLogger();

            Log.Logger = log;
        }

        public static void Exec()
        {
            var dc = new Dictionary<object, object>()
            {
                { "a","1" },
                { "b","2" },
                { "c","3" }
            };
            Log.Information("dc = > {dc}", dc);
        }
    }
}
